package com.example.vv.controller;

import com.example.vv.service.DeveloperService;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author w.dehai.2024/6/7.23:07
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/developer")
public class DeveloperController {

    private final DeveloperService developerService;

    private String name = "w.dehai";

    @GetMapping("/index")
    public List<String> index(Long id) {

        developerService.index();

        log.info("id: {}", id);

        for (int i = 0; i < 10; i++) {
            System.err.println(i);
        }

        System.err.println(name);

        List<String> resp = new ArrayList<>();
        resp.add("1");
        resp.add("2");

        developerService.insert();

        CompletableFuture.runAsync(() -> {
            System.err.println(123456);
        });
        System.err.println("ok");

        CompletableFuture.runAsync(() -> {
            //            while (true) {
            //                System.err.println(123);
            //            }
        });

        return resp;
    }

    @GetMapping("/index2")
    public List<String> index2(Long id) {
        return new ArrayList<>();
    }
}
